var webpack = require("webpack");
var path = require("path");

var node_modules = path.resolve(__dirname, 'node_modules');
var bower_components = path.resolve(__dirname, 'bower_components');
var pathToReact = path.resolve(node_modules, 'react/dist/react.min.js');
var pathToJquery = path.resolve(bower_components, 'jquery/dist/jquery.min.js');

var BUILD_DIR = path.resolve(__dirname, "build/client");
var APP_DIR = path.resolve(__dirname, "src");

module.exports = {
    entry: APP_DIR + "/main.jsx",
    output: {
        path: BUILD_DIR,
        filename: "main.bundle.js"
    },
    module: {
        noParse: [pathToReact],// webpack尝试去解析压缩文件时，这种行为是不允许的。
        loaders: [{
            test: /\.js$/,
            include: APP_DIR,
            exclude: /node_modules/,
            loader: "babel-loader"
        }, {
            test: /\.jsx$/,
            include: APP_DIR,
            exclude: /node_modules/,
            loader: "babel-loader"
        }, {
            test: /\.css$/,
            loader: 'style!css'
        }, {
            test: /\.less$/,
            loader: 'style!css!less'
        }, {
            test: /\.(png|jpg)$/,
            loader: 'url?limit=25000'
        }]
    },
    resolve: {
        extensions: ["", ".js", ".jsx"],
        alias: {
            'react': pathToReact,
            "react-dom": "react-dom/dist/react-dom.min.js",
            "jquery":pathToJquery
        }
    },
    plugins: [
        new webpack.ProvidePlugin({
            "React": "react",
            "ReactDOM":"react-dom",
            "$":"jquery",
            "jQuery":"jquery"
        })
    ]
};
